package com.xhtt.smart.card.server.init;


import com.xhtt.smart.card.server.code.MessageServerDecoder;
import com.xhtt.smart.card.server.code.MessageServerEncoder;
import com.xhtt.smart.card.server.handle.NettyHandle;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.timeout.IdleStateHandler;

/**
 * @author wangze
 * @date 2018-07-03 13:42.
 **/

public class NettyServerInitializer extends ChannelInitializer<Channel> {
    @Override
    protected void initChannel(Channel ch) throws Exception {
        ch.pipeline()
                //60秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中
                .addLast(new IdleStateHandler(60, 0, 0))
                .addLast(new MessageServerDecoder())
                .addLast(new MessageServerEncoder())
                .addLast(new NettyHandle());
    }
}
